﻿/*
 * Created by SharpDevelop.
 * User: Intel
 * Date: 04.06.2014
 * Time: 12:26
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Text.RegularExpressions;
using System.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data.Sql;
using System.Collections.Generic;


namespace Region
{
  /// <summary>
  /// Таблица для обезличивания.
  /// </summary>
  [Database]
  public class BD_FIO: DataContext
  {
  	#if DEBUG
    //public BD_FIO() : base(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=BD_FIO;Integrated Security=True;Pooling=False ") { }  	
    public BD_FIO(Engine engine):base(engine.config.getValue<String>("BD_FIO","")){}
    public BD_FIO(String Link):base(Link){}
    #else
    public BD_FIO(Engine engine):base(engine.config.getValue<String>("BD_FIO","")){}
    public BD_FIO(String Link):base(Link){}
    #endif
    public Table<Links> Links;//{get{return this.GetTable<>}}
    public Table<Address> Address;
  }
  /// <summary>
  /// Description of IP.
  /// </summary>
  [Table] public class Links
  {
    [Column(IsPrimaryKey = true,IsDbGenerated = true)] public Guid LinksUID{get;set;}
    [Column(IsDbGenerated = true)] public String ID{get;set;}
    [Column] public String FirstName{get;set;}
    [Column] public String MiddleName{get;set;}
    [Column] public String LastName{get;set;}
    [Column(IsDbGenerated = true)] public String Username{get;set;}
    [Column(IsDbGenerated = true)] public Int64 Number{get;set;}
  }
  [Table] public class Address
  {
    [Column(IsPrimaryKey = true,IsDbGenerated = true)] public Guid AddressUID{get;set;}
    [Column] public Guid LinksUID{get;set;}
    [Column] public String Region{get;set;}
    [Column] public String Raion{get;set;}
    [Column] public String City{get;set;}
    [Column] public String Street{get;set;}
    [Column] public String Settlement{get;set;}
    [Column] public String Home{get;set;}
    [Column] public String Structure{get;set;}
    [Column] public String Room{get;set;}
    public override String ToString()
    {
          var L = new List<String>();
          L.Add(Region);
          if (Raion.Trim()!="")L.Add(Raion);
          if (City.Trim()!="") L.Add(City);
          if (Settlement.Trim()!="") L.Add(Settlement);
          L.Add(Street);
          L.Add(Home+((Structure.Trim()!="")?("-"+Structure):("")));
          if (Room.Trim()!="") L.Add(Room);
          return String.Join(", ",L.ToArray());
    }
  }
 
}

